// 路由使用Hash模式
import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
// 导入管理员和用户的组件
import MangerlndexView from '@/views/manager/MangerlndexView.vue'
import MangerListView from '@/views/manager/MangerListView.vue'
import UserListView from '@/views/manager/UserListView.vue'

// 导入轮播图管理相关组件
import BannerlndexView from '@/views/banner/BannerlndexView.vue'
import BannerListView from '@/views/banner/BannerListView.vue'
import AddBannerView from '@/views/banner/AddBannerView.vue'

export const routes=[
  {
    path: '/',
    name: 'home',
    component: HomeView,
    //路由嵌套，配置二级路由
    children:[
      {
        path:'manager',
        name:'manager',
        label:'账户管理',
        component: MangerlndexView,
        // 配置三级路由
        children:[
          {
            path:'managerlist',
            name:'managerlist',
            label:'管理员列表',
            component: MangerListView,
          },
          {
            path:'userlist',
            name:'userlist',
            label:'用户列表',
            component: UserListView
          }
        ]
      },
      {
        path:'banner',
        name:'banner',
        label:'轮播图管理',
        component:BannerlndexView,
        children:[
          {
          path:'bannerlist',
          name:'bannerlist',
          label:'轮播图列表',
          component:BannerListView
        },
        {
          path:'addbanner',
          name:'addbanner',
          label:'添加轮播图',
          component:AddBannerView
        }
        ]
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    // 路由懒加载
    component: () => import('../views/LoginView.vue')
  },
]

const router = createRouter({
  // 路由模式
  history: createWebHashHistory(import.meta.env.BASE_URL),
  // 路由规则
  routes
})

export default router
